use serde::{
    de::{DeserializeSeed, IntoDeserializer},
    Deserializer,
};

use crate::RedisError;

use super::Value;

impl<'de, 'a> serde::de::Deserializer<'de> for &'a Value {
    type Error = RedisError;

    fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        match self {
            Value::Nil => self.deserialize_option(visitor),
            Value::SimpleString(_) => self.deserialize_string(visitor),
            Value::Integer(_) => self.deserialize_i64(visitor),
            Value::BigNumber(_) => self.deserialize_i128(visitor),
            Value::Double(_) => self.deserialize_f64(visitor),
            Value::BulkString(_) => self.deserialize_string(visitor),
            Value::BulkError(_) => self.deserialize_string(visitor),
            Value::Map(_) => self.deserialize_map(visitor),
            Value::Boolean(_) => self.deserialize_bool(visitor),
            Value::Array(_) => self.deserialize_seq(visitor),
            Value::Set(_) => self.deserialize_seq(visitor),
            Value::Pushes(_) => self.deserialize_seq(visitor),
            Value::SimpleError(_) => self.deserialize_string(visitor),
            Value::VerbatimString(_, _) => self.deserialize_string(visitor),
        }
    }

    fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Boolean(val) => val,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to boolean".to_string(),
                ));
            }
        };
        visitor.visit_bool(*result)
    }

    fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Integer(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to i8".to_string(),
                ));
            }
        };
        if result < i8::MIN as i64 || result > i8::MAX as i64 {
            Err(RedisError::SerdeDeserialize(
                "the value is out of i8 range".to_string(),
            ))
        } else {
            visitor.visit_i8(result as i8)
        }
    }

    fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Integer(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to i16".to_string(),
                ));
            }
        };
        if result < i16::MIN as i64 || result > i16::MAX as i64 {
            Err(RedisError::SerdeDeserialize(
                "the value is out of i16 range".to_string(),
            ))
        } else {
            visitor.visit_i16(result as i16)
        }
    }

    fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Integer(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to i32".to_string(),
                ));
            }
        };
        if result < i32::MIN as i64 || result > i32::MAX as i64 {
            Err(RedisError::SerdeDeserialize(
                "the value is out of i32 range".to_string(),
            ))
        } else {
            visitor.visit_i32(result as i32)
        }
    }

    fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Integer(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to i64".to_string(),
                ));
            }
        };
        visitor.visit_i64(result)
    }

    fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Integer(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to u8".to_string(),
                ));
            }
        };
        if result < u8::MIN as i64 || result > u8::MAX as i64 {
            Err(RedisError::SerdeDeserialize(
                "the value is out of i8 range".to_string(),
            ))
        } else {
            visitor.visit_u8(result as u8)
        }
    }

    fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Integer(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to u16".to_string(),
                ));
            }
        };
        if result < u16::MIN as i64 || result > u16::MAX as i64 {
            Err(RedisError::SerdeDeserialize(
                "the value is out of u16 range".to_string(),
            ))
        } else {
            visitor.visit_u16(result as u16)
        }
    }

    fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Integer(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to u32".to_string(),
                ));
            }
        };
        if result < u32::MIN as i64 || result > u32::MAX as i64 {
            Err(RedisError::SerdeDeserialize(
                "the value is out of u32 range".to_string(),
            ))
        } else {
            visitor.visit_u32(result as u32)
        }
    }

    fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Integer(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to u64".to_string(),
                ));
            }
        };
        visitor.visit_u64(result as u64)
    }

    fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Double(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to u64".to_string(),
                ));
            }
        };
        if result < f32::MIN as f64 || result > f32::MAX as f64 {
            Err(RedisError::SerdeDeserialize(
                "the value is out of f32 range".to_string(),
            ))
        } else {
            visitor.visit_f32(result as f32)
        }
    }

    fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Double(buf) => *buf,
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to u64".to_string(),
                ));
            }
        };
        visitor.visit_f64(result)
    }

    fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::SimpleString(buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize(
                    "the simple string couldn't deserialize to str",
                    err,
                )
            })?,
            Value::BulkString(buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize(
                    "the bulk string couldn't deserialize to str",
                    err,
                )
            })?,
            Value::BulkError(buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize("the bulk error couldn't deserialize to str", err)
            })?,
            Value::SimpleError(buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize(
                    "the simple error couldn't deserialize to str",
                    err,
                )
            })?,
            Value::VerbatimString(_, buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize(
                    "the verbatim string couldn't deserialize to str",
                    err,
                )
            })?,
            Value::BigNumber(val) => &val.to_string(),
            Value::Boolean(val) => &val.to_string(),
            Value::Double(val) => &val.to_string(),
            Value::Integer(val) => &val.to_string(),
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to char".to_string(),
                ));
            }
        };
        let len = result.chars().count();
        if len == 1 {
            visitor.visit_char(result.chars().next().unwrap())
        } else {
            Err(RedisError::RespDeserialize(format!(
                "can't parse {result} to char, the str has {len} chars"
            )))
        }
    }

    fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Nil => {
                return Err(RedisError::SerdeDeserialize("the value is nil".to_string()));
            }
            Value::SimpleString(buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize(
                    "the simple string couldn't deserialize to str",
                    err,
                )
            })?,
            Value::BulkString(buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize(
                    "the bulk string couldn't deserialize to str",
                    err,
                )
            })?,
            Value::BulkError(buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize("the bulk error couldn't deserialize to str", err)
            })?,
            Value::SimpleError(buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize(
                    "the simple error couldn't deserialize to str",
                    err,
                )
            })?,
            Value::VerbatimString(_, buf) => std::str::from_utf8(buf).map_err(|err| {
                RedisError::new_serde_deserialize(
                    "the verbatim string couldn't deserialize to str",
                    err,
                )
            })?,
            Value::BigNumber(val) => &val.to_string(),
            Value::Boolean(val) => &val.to_string(),
            Value::Double(val) => &val.to_string(),
            Value::Integer(val) => &val.to_string(),
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to str".to_string(),
                ));
            }
        };
        visitor.visit_str(result)
    }

    fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::Nil => {
                return Err(RedisError::SerdeDeserialize("the value is nil".to_string()));
            }
            Value::SimpleString(buf) => std::str::from_utf8(buf)
                .map_err(|err| {
                    RedisError::new_serde_deserialize(
                        "the simple string couldn't deserialize to str",
                        err,
                    )
                })?
                .to_string(),
            Value::BulkString(buf) => std::str::from_utf8(buf)
                .map_err(|err| {
                    RedisError::new_serde_deserialize(
                        "the bulk string couldn't deserialize to str",
                        err,
                    )
                })?
                .to_string(),
            Value::BulkError(buf) => std::str::from_utf8(buf)
                .map_err(|err| {
                    RedisError::new_serde_deserialize(
                        "the bulk error couldn't deserialize to str",
                        err,
                    )
                })?
                .to_string(),
            Value::SimpleError(buf) => std::str::from_utf8(buf)
                .map_err(|err| {
                    RedisError::new_serde_deserialize(
                        "the simple error couldn't deserialize to str",
                        err,
                    )
                })?
                .to_string(),
            Value::VerbatimString(_, buf) => std::str::from_utf8(buf)
                .map_err(|err| {
                    RedisError::new_serde_deserialize(
                        "the verbatim string couldn't deserialize to str",
                        err,
                    )
                })?
                .to_string(),
            Value::BigNumber(val) => val.to_string(),
            Value::Boolean(val) => val.to_string(),
            Value::Double(val) => val.to_string(),
            Value::Integer(val) => val.to_string(),
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to string".to_string(),
                ));
            }
        };
        visitor.visit_string(result)
    }

    fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::SimpleString(buf) => buf,
            Value::BulkString(buf) => buf,
            Value::BulkError(buf) => buf,
            Value::SimpleError(buf) => buf,
            Value::VerbatimString(_, buf) => buf,
            Value::BigNumber(val) => &i128::to_be_bytes(*val)[..],
            Value::Boolean(val) => match *val {
                true => b"1",
                false => b"0",
            },
            Value::Double(val) => &f64::to_be_bytes(*val)[..],
            Value::Integer(val) => &i64::to_be_bytes(*val)[..],
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to bytes".to_string(),
                ));
            }
        };
        visitor.visit_bytes(result)
    }

    fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let result = match self {
            Value::SimpleString(buf) => buf.to_vec(),
            Value::BulkString(buf) => buf.to_vec(),
            Value::BulkError(buf) => buf.to_vec(),
            Value::SimpleError(buf) => buf.to_vec(),
            Value::VerbatimString(_, buf) => buf.to_vec(),
            Value::BigNumber(val) => i128::to_be_bytes(*val).to_vec(),
            Value::Boolean(val) => match *val {
                true => b"1".to_vec(),
                false => b"0".to_vec(),
            },
            Value::Double(val) => f64::to_be_bytes(*val).to_vec(),
            Value::Integer(val) => i64::to_be_bytes(*val).to_vec(),
            _ => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type couldn't deserialize to bytes buf".to_string(),
                ));
            }
        };
        visitor.visit_byte_buf(result)
    }

    fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        match self {
            Value::Nil => visitor.visit_none(),
            _ => visitor.visit_some(self),
        }
    }

    fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        visitor.visit_unit()
    }

    fn deserialize_unit_struct<V>(
        self,
        _name: &'static str,
        visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        self.deserialize_unit(visitor)
    }

    fn deserialize_newtype_struct<V>(
        self,
        _name: &'static str,
        visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        visitor.visit_newtype_struct(self)
    }

    fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        match self {
            Value::Nil
            | Value::Integer(_)
            | Value::BigNumber(_)
            | Value::Double(_)
            | Value::Boolean(_)
            | Value::Map(_) => Err(RedisError::SerdeDeserialize(
                "the value type doesn't support seq".to_string(),
            )),
            Value::BulkString(_)
            | Value::BulkError(_)
            | Value::SimpleString(_)
            | Value::SimpleError(_)
            | Value::VerbatimString(_, _) => visitor.visit_seq(SeqAccess { pos: 0, de: self }),
            Value::Array(_) | Value::Set(_) | Value::Pushes(_) => {
                visitor.visit_seq(SeqAccess { pos: 0, de: self })
            }
        }
    }

    fn deserialize_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        self.deserialize_seq(visitor)
    }

    fn deserialize_tuple_struct<V>(
        self,
        _name: &'static str,
        _len: usize,
        visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        self.deserialize_seq(visitor)
    }

    fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        match self {
            Value::Map(map) => visitor.visit_map(MapAccess::new(map)),
            _ => Err(RedisError::SerdeDeserialize(
                "the value type doesn't support map".to_string(),
            )),
        }
    }

    fn deserialize_struct<V>(
        self,
        _name: &'static str,
        _fields: &'static [&'static str],
        visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        match self {
            Value::Map(map) => visitor.visit_map(MapAccess::new(map)),
            _ => Err(RedisError::SerdeDeserialize(
                "the value type doesn't support struct".to_string(),
            )),
        }
    }

    fn deserialize_enum<V>(
        self,
        _name: &'static str,
        _variants: &'static [&'static str],
        visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        let buf = match self {
            Value::SimpleString(data) => data,
            Value::BulkString(data) => data,
            Value::BulkError(data) => data,
            Value::SimpleError(data) => data,
            Value::VerbatimString(_, data) => data,
            Value::Nil
            | Value::Integer(_)
            | Value::BigNumber(_)
            | Value::Double(_)
            | Value::Map(_)
            | Value::Boolean(_)
            | Value::Array(_)
            | Value::Set(_)
            | Value::Pushes(_) => {
                return Err(RedisError::SerdeDeserialize(
                    "the value type doesn't support enum".to_string(),
                ));
            }
        };

        match std::str::from_utf8(buf) {
            Ok(val) => visitor.visit_enum(val.into_deserializer()),
            Err(err) => Err(RedisError::SerdeDeserialize(format!("{err}"))),
        }
    }

    fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        self.deserialize_str(visitor)
    }

    fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        self.deserialize_any(visitor)
    }
}

struct MapAccess<'a> {
    de: &'a Vec<(Value, Value)>,
    pos: usize,
}

impl<'a> MapAccess<'a> {
    fn new(map: &'a Vec<(Value, Value)>) -> MapAccess<'a> {
        Self { de: map, pos: 0 }
    }
}

impl<'de, 'a> serde::de::MapAccess<'de> for MapAccess<'a> {
    type Error = RedisError;

    fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
    where
        K: DeserializeSeed<'de>,
    {
        if let Some((key, _)) = self.de.iter().nth(self.pos) {
            seed.deserialize(key).map(Some)
        } else {
            Ok(None)
        }
    }

    fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error>
    where
        V: DeserializeSeed<'de>,
    {
        if let Some((_, value)) = self.de.iter().nth(self.pos) {
            self.pos += 1;
            seed.deserialize(value)
        } else {
            Err(RedisError::SerdeDeserialize(
                "the key is out of Map range in MapAccess".to_string(),
            ))
        }
        // if let Some(cur_key) = self.cur_key {
        //     if let Some(val) = self.de.get(cur_key) {
        //         self.pos += 1;
        //         seed.deserialize(val)
        //     } else {
        //         Err(RedisError::SerdeDeserialize(
        //             "the value is out of Map range in MapAccess".to_string(),
        //         ))
        //     }
        // } else {
        //     Err(RedisError::SerdeDeserialize(
        //         "the key is out of Map range in MapAccess".to_string(),
        //     ))
        // }
    }
}

struct SeqAccess<'a> {
    de: &'a Value,
    pos: usize,
}

impl<'de, 'a> serde::de::SeqAccess<'de> for SeqAccess<'a> {
    type Error = RedisError;

    fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
    where
        T: DeserializeSeed<'de>,
    {
        match self.de {
            Value::SimpleString(array)
            | Value::BulkString(array)
            | Value::BulkError(array)
            | Value::SimpleError(array) => {
                if let Some(item) = array.get(self.pos) {
                    self.pos += 1;
                    seed.deserialize(U8Deserializer { de: *item }).map(Some)
                } else {
                    Ok(None)
                }
            }
            Value::Pushes(array) | Value::Set(array) | Value::Array(array) => {
                if let Some(item) = array.get(self.pos) {
                    self.pos += 1;
                    seed.deserialize(item).map(Some)
                } else {
                    Ok(None)
                }
            }
            Value::Nil => todo!(),
            Value::Integer(_) => todo!(),
            Value::BigNumber(_) => todo!(),
            Value::Double(_) => todo!(),
            Value::Map(_) => todo!(),
            Value::Boolean(_) => todo!(),
            _ => Err(RedisError::SerdeDeserialize(
                "the type of de does't be Seq in SeqAccess".to_string(),
            )),
        }
    }
}

struct U8Deserializer {
    de: u8,
}

impl<'de, 'a: 'de> Deserializer<'de> for U8Deserializer {
    type Error = RedisError;

    fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_bool<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_i8<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_i16<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_i32<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_i64<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        visitor.visit_u8(self.de)
    }

    fn deserialize_u16<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_u32<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_u64<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_f32<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_f64<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_char<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_str<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_string<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_bytes<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_byte_buf<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_option<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_unit<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_unit_struct<V>(
        self,
        _name: &'static str,
        _visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_newtype_struct<V>(
        self,
        _name: &'static str,
        _visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_seq<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_tuple<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_tuple_struct<V>(
        self,
        _name: &'static str,
        _len: usize,
        _visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_map<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_struct<V>(
        self,
        _name: &'static str,
        _fields: &'static [&'static str],
        _visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_enum<V>(
        self,
        _name: &'static str,
        _variants: &'static [&'static str],
        _visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_identifier<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }

    fn deserialize_ignored_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        unimplemented!()
    }
}
